/*
 * @Author: Laputa
 * @Version: V0.1
 * @Date: 2023-05-30 15:44:54
 * @LastEditors: Laputa
 * @LastEditTime: 2023-09-06 10:35:40
 * @Description: 
 * 
 * Copyright (c) 2023 by Levetop, All Rights Reserved. 
 */

#include "LT168_Config.h"

typedef void (*vfuntion)(void);
extern void __start();
void DummyHandler(void)
{
    // COMMENT("WARNING: Default dummy interrupt handler entered \n");
    //	LTPrintf("DummyHandler\r\n");
}
void Reset_Handler(void)
{
	__start();
    // COMMENT("WARNING: Default dummy interrupt handler entered \n");
    //	LTPrintf("Reset_Handler\r\n");
}

void  Misaligned_Access(void)
{
    // COMMENT("WARNING: Unexpected Misaligned Access exception taken \n");
    //	LTPrintf("Misaligned_Access\r\n");
}

void Access_Error(void)
{
    // COMMENT("WARNING: Unexpected Access Error exception taken \n");
    //	LTPrintf("Access_Error\r\n");
}

void Illegal_Instrn(void)
{
    // COMMENT("WARNING: Unexpected Illegal_Instrn exception taken \n");
    //	LTPrintf("Illegal_Instrn\r\n");
}

void Breakpoint_Exception(void)
{
    // COMMENT("WARNING: Unexpected Breakpoint exception taken \n");
    //	LTPrintf("Breakpoint_Exception\r\n");
}

void Unrecoverable_Error(void)
{
    //  PSPRINTF("WARNING: Unexpected Unrecoverable_Error exception taken \n");
    //	LTPrintf("Unrecoverable_Error\r\n");
}
void __attribute__((weak)) EPT_Handler(void);
void __attribute__((weak)) ADC_Handler(void);
void __attribute__((weak)) PVD_Handler(void);

void __attribute__((weak)) QSPI0_Handler(void);
void __attribute__((weak)) QSPI1_Handler(void);
void __attribute__((weak)) QSPI2_Handler(void);
void __attribute__((weak)) PIT0_Handler(void);
void __attribute__((weak)) PIT1_Handler(void);
void __attribute__((weak)) PIT2_Handler(void);
void __attribute__((weak)) PIT3_Handler(void);
void __attribute__((weak)) DMA_Handler(void);
void __attribute__((weak)) SCI0_Handler(void);
void __attribute__((weak)) SCI1_Handler(void);
void __attribute__((weak)) SCI2_Handler(void);
void __attribute__((weak)) EPORT0_Handler(void);
void __attribute__((weak)) EPORT1_Handler(void);
void __attribute__((weak)) EPORT2_Handler(void);
void __attribute__((weak)) PWM0_Handler(void);
void __attribute__((weak)) PWM1_Handler(void);
void __attribute__((weak)) COMP0_Handler(void);
void __attribute__((weak)) COMP1_Handler(void);
void __attribute__((weak)) USB_Handler(void);
void __attribute__((weak)) I2C_Handler(void);
void __attribute__((weak)) WDT_Handler(void);
void __attribute__((weak)) RTC_Handler(void);
void __attribute__((weak)) CANBUS_IFRH_Handler(void);
void __attribute__((weak)) CANBUS_BOFF_Handler(void);
void __attribute__((weak)) CANBUS_ERR_Handler(void);
void __attribute__((weak)) CANBUS_TWRN_Handler(void);
void __attribute__((weak)) CANBUS_RWRN_Handler(void);
void __attribute__((weak)) CANBUS_WKUP_Handler(void);
void __attribute__((weak)) BLENDER_Handler(void);
void __attribute__((weak)) RGBC_Handler(void);




vfuntion const VecTable[] =
{
	__start,
    Misaligned_Access,
    Access_Error,
    DummyHandler,
    Illegal_Instrn,
    0,
    0,
    Breakpoint_Exception,
    Unrecoverable_Error,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    EPT_Handler,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    ADC_Handler,
    QSPI0_Handler,
    SCI0_Handler,
    COMP0_Handler,
    COMP1_Handler,
    DMA_Handler,
    WDT_Handler,
    PWM0_Handler,
    PWM1_Handler,
    PIT0_Handler,
    PIT1_Handler,
    PIT2_Handler,
    PIT3_Handler,
    RTC_Handler,
    USB_Handler,
    I2C_Handler,
    EPORT2_Handler,
    PVD_Handler,
    CANBUS_IFRH_Handler,
    CANBUS_BOFF_Handler,
    CANBUS_ERR_Handler,
    CANBUS_TWRN_Handler,
    CANBUS_RWRN_Handler,
    CANBUS_WKUP_Handler,
    BLENDER_Handler,
    RGBC_Handler,
    QSPI1_Handler,
    QSPI2_Handler,
    SCI1_Handler,
    SCI2_Handler,
    EPORT0_Handler,
    EPORT1_Handler,
};

extern char _end_text[];

extern char _start_data[];
extern char _end_data[];

extern char _start_bss[];
extern char _end_bss[];

void _init_variable(void)
{
	int i;
    /* if the start of data (dst)
     is not equal to end of text (src) then
     copy it, else it's already in the right place
     */
    if (_start_data != _end_text)
    {
        for (i = 0; i < (_end_data - _start_data); i++)
        	_start_data[i] = _end_text[i];
    }

    /* zero the bss
     */

	for (i = 0; i < (_end_bss - _start_bss); i++)
		_start_bss[i] = 0;
}
